package com.mrslu.signkk.configuration;

import com.mrslu.signkk.interceptor.RequestInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 卢斌
 */
@Configuration
public class ConnectorConfiguration implements WebMvcConfigurer {

    private final RequestInterceptor interceptor;


    @Autowired
    public ConnectorConfiguration(RequestInterceptor interceptor) {
        this.interceptor = interceptor;
    }


    /**
     * 配置一个拦截器，这里会拦截所有请求
     *
     * @param interceptorRegistry   配置拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry interceptorRegistry){
        String[] addPath = {"/**"};
        interceptorRegistry.addInterceptor(interceptor).addPathPatterns(addPath);
    }
}